package org.vineatoum.view.utils;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.Arrays;

import org.vineatoum.business.Exploitation;
import org.vineatoum.business.abstraction.BusinessAbstract;
import org.vineatoum.business.state.Benne;
import org.vineatoum.business.state.abstraction.VinAbstract;

public class TransferableBusinessAbstract implements Transferable {

	
	private static final DataFlavor nodeFlavor  = new DataFlavor( Exploitation.class,
			   DataFlavor.javaJVMLocalObjectMimeType);
	protected static final DataFlavor benneFlavor  = new DataFlavor( Benne.class,
			   DataFlavor.javaJVMLocalObjectMimeType);
	private BusinessAbstract va;
	public TransferableBusinessAbstract(BusinessAbstract data) {
		va = data;
	
	}


	@Override
	public Object getTransferData(DataFlavor arg0)
			throws UnsupportedFlavorException, IOException {
		// TODO Auto-generated method stub
		return va;
	}

	@Override
	public DataFlavor[] getTransferDataFlavors() {
		// TODO Auto-generated method stub
		DataFlavor[] result = {nodeFlavor,benneFlavor};
		return result;
	}
		
	@Override
	public boolean isDataFlavorSupported(DataFlavor arg0) {
		// TODO Auto-generated method stub
		return Arrays.asList(getTransferDataFlavors()).contains(arg0);
	}


	/**
	 * @return the nodeflavor
	 */
	public static DataFlavor getNodeflavor() {
		return nodeFlavor;
	}
	
}